<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="product" tagdir="/WEB-INF/tags/product"%>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>

<title><fmt:message key="product.search.advancedSearch"/></title>

<form name="advancedSearchForm" id="advancedSearchForm" onsubmit="return validateAdvancedSearchForm();" method="get" action="${ctxPath}/searchProd.html">
	<div class="advance_search">
		<div class="top"><span><fmt:message key="product.search.advancedSearch"/></span></div>
		<div class="content">
			<div class="block1">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">
						<tr>
								<th width="15%"><fmt:message key="product.search.keyword"/>:</th>
								<td><input name="keywords" type="text" class="inputtxt2" style="width:290px" /></td>
						</tr>
						<tr>
								<th><fmt:message key="product.search.keyword.excluded"/>:</th>
								<td><input name="excludedKeywords" type="text" class="inputtxt2" style="width:200px" /></td>
						</tr>
						<tr>
								<th><fmt:message key="product.search.priceSpan"/>:</th>
								<td><input name="lowestPrice" id="lowestPrice" type="text" class="inputtxt2" style="width:70px" /> <fmt:message key="product.yuan"/> ~ 
								<input name="highestPrice" id="highestPrice" type="text" class="inputtxt2" style="width:70px" /> <fmt:message key="product.yuan"/></td>
						</tr>
						<tr>
								<th><fmt:message key="product.search.productCode"/>:</th>
								<td><input name="productCode" type="text" class="inputtxt2" style="width:120px" /></td>
						</tr>
						<tr>
								<th><fmt:message key="product.search.productSkuCode"/>:</th>
								<td><input name="productSkuCode" type="text" class="inputtxt2" style="width:120px" /></td>
						</tr>
				</table>
			</div>
			<div class="block1">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">
						<tr>
								<th width="15%"><fmt:message key="product.search.category"/>：</th>
								<td>
									<ul class="select clearfix">
										<catalog:productCategoryTree categoryId="1" depth="1"  returnRootCategoryName="indexRootCategory">
											<c:forEach items="${indexRootCategory.children}" var="category">
												<li>
													<input id="category_${category.categoryId}" name="categoryPaths" type="checkbox" value="${category.categoryPath}" /> 
													<label for="category_${category.categoryId}">${category.categoryName}</label>
												</li>
											</c:forEach>
										</catalog:productCategoryTree>
									</ul>	
								</td>
						</tr>
				</table>
			</div>
			<div class="block1">
				<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">
						<tr>
								<th width="15%"><fmt:message key="product.search.brand"/>：</th>
								<td>
									<ul class="select clearfix">
										<product:allBrands returnBrandListName="brandList">
											<c:forEach items="${brandList}" var="brand">
													<li>
														<input id="brand_${brand.brandId}" name="brandIds" type="checkbox" value="${brand.brandId}" /> 
														<label for="brand_${brand.brandId}">${brand.brandName}</label>
													</li>
											</c:forEach>
										</product:allBrands>
									</ul>
								</td>
						</tr>
				</table>
			</div>
			<div class="do"><input name="" type="image" src="${txtImagePath}/btn_search_04.gif" alt="<fmt:message key="button.search"/>" /></div>
		</div>
	</div>
</form>

<c:if test="${appConfig.isOpenFulltextSearch}">
	<form name="solrSearchForm" id="solrSearchForm"  method="get" action="${ctxPath}/globalSearch.html" onsubmit="return validateFormWithMsg(this)">
		<div class="advance_search">
			<div class="top"><span><fmt:message key="globalSearch.title"/></span></div>
			<div class="content">
				<div class="block1">
					<table width="100%" border="0" cellspacing="0" cellpadding="0" class="t1">
							<tr>
									<th width="15%"><fmt:message key="globalSearch.searchWord"/>:</th>
									<td><input id="gkeywords" name="keywords" type="text" class="inputtxt2" style="width:290px" /></td>
							</tr>
					</table>
				</div>
				<div class="do"><input name="" type="image" src="${txtImagePath}/btn_search_04.gif" alt="<fmt:message key="button.search"/>" /></div>
			</div>
		</div>
	</form>
</c:if>

<c:set var="probizJs_validation" value="true" scope="request"/>
<script type="text/javascript">
function validateAdvancedSearchForm() {
	var rePrice = new RegExp("^[\\d,]*(\\.\\d{1,2})?$");
	if ((!rePrice.test($("lowestPrice").value)) || (!rePrice.test($("highestPrice").value))) {
		alert(__vaMsg.price);
		return false;
	}
	return true;
}

$j(document).ready(function(){
	<c:if test="${appConfig.isOpenFulltextSearch}">
		applyValidate($('gkeywords'),"required");
	</c:if>
});
	
</script>